/**
 * Created by Administrator on 2015/6/2.
 */

var User = require('../models/User');


exports.register = function(username, password, nicename, email, callback) {

    //四个值均不能为空
    if (!username || !password || !nicename || !email) {
        return callback(null);
    }

    var user = new User(username, password, nicename, email);
    user.save(function (err, docs) {
        if (err) {
            console.log('添加用户到数据库失败');
            return callback(null);
        }

        console.log('成功添加一个用户到数据库');
        callback(docs.ops);
    });
}

